 const express = require('express');
 const router = express.Router();
 const Database = require('../model/connectDatabase');
 const {SuccessModel,ErrorModel} = require('../model/resData');

router.post('/',(req,res,next)=>{
    let database = new Database().mysql;
    let sql = 'insert into users(username,password) values(?,?)';
    let mag = [req.body.username,req.body.password]
    database.query(sql,mag,(err,data)=>{
        if(err){
            res.send(new ErrorModel(err,'注册失败'));
        }else if(data){
            res.send(new SuccessModel(data,'注册成功'));
        }
        
    })
})

module.exports = router